import { FormProps, FormSchema } from '@/components/Table'
import { BasicColumn } from '@/components/Table/src/types/table'
import dayjs, { Dayjs } from 'dayjs'
import { getBeforeTime } from '@/utils/dateUtil'

export function getCompanyBasicColums(): BasicColumn[] {
  return [
    {
      title: '用户手机号码',
      customEllipsis: true,
      width: 100,
      fixed: 'left',
      dataIndex: 'phoneNumber'
    },
    {
      title: '计费类型',
      width: 80,
      dataIndex: 'chargeType'
    },
    {
      title: '渠道名称',
      width: 150,
      customEllipsis: true,
      dataIndex: 'channelName'
    },
    {
      title: '付费类型',
      width: 80,
      dataIndex: 'payFlag'
    },
    {
      title: '有效期止',
      width: 140,
      dataIndex: 'endDate'
    },
    {
      title: '剩余Pai豆',
      align: 'right',
      width: 110,
      dataIndex: 'balanceScore'
    },
    {
      title: '咨询次数',
      width: 90,
      align: 'right',
      dataIndex: 'chatCount'
    },
    {
      title: '邀请用户数',
      width: 90,
      align: 'right',
      dataIndex: 'inviteCount'
    },
    {
      title: '点赞数',
      width: 90,
      align: 'right',
      dataIndex: 'likeCount'
    },
    {
      title: '点踩数',
      width: 90,
      align: 'right',
      dataIndex: 'badCount'
    },
    {
      title: '最近一次咨询时间',
      width: 140,
      dataIndex: 'lastChatTime'
    },
    {
      title: '最近一次访问时间',
      width: 140,
      dataIndex: 'lastVisitTime'
    },
    {
      title: '关联企业名称',
      width: 140,
      customEllipsis: true,
      dataIndex: 'enterpriseName'
    },
    {
      title: '关联企业税号',
      width: 120,
      dataIndex: 'taxNo'
    },
    {
      title: '创建时间',
      width: 140,
      dataIndex: 'createTime'
    },
    {
      title: '备注',
      width: 140,
      customEllipsis: true,
      dataIndex: 'userMark'
    }
  ]
}

export function getSearchFormConfig(): Partial<FormProps> {
  return {
    // labelWidth: 120,
    labelCol: { style: { width: '70px', whiteSpace: 'normal', lineHeight: '14px', marginLeft: '12px' } },
    baseColProps: {
      span: 6,
      md: 10,
      xl: 8,
      xxl: 6
    },
    schemas: [
      {
        field: '[creatTimeBegin,creatTimeEnd]',
        label: '创建时间',
        component: 'RangePicker',
        defaultValue: [getBeforeTime(31, 'day'), getBeforeTime(0, 'day')],
        componentProps: {
          valueFormat: 'YYYY-MM-DD',
          format: 'YYYY-MM-DD',
          disabledDate: (current: Dayjs) => {
            return current && current.isAfter(dayjs().startOf('day'), 'day')
          }
        }
      },
      {
        field: 'channelNoList',
        label: '渠道名称',
        component: 'TreeSelect',
        slot: 'channelCode'
      },
      {
        field: 'phoneNumber',
        label: '用户手机号',
        component: 'Input',
        componentProps: {
          maxLength: 11
        }
      },
      {
        field: 'chatCount',
        label: '咨询次数',
        component: 'Input',
        slot: 'chatCount'
      },
      {
        field: 'inviteCount',
        label: '邀请用户数',
        component: 'Input',
        slot: 'inviteCount'
      },
      {
        field: 'likeCount',
        label: '点赞数',
        component: 'Input',
        slot: 'likeCount'
      },
      {
        field: 'badCount',
        label: '点踩数',
        component: 'Input',
        slot: 'badCount'
      },
      // {
      //   field: '[endDateBegin,endDateEnd]',
      //   label: '有效期止',
      //   component: 'RangePicker',
      //   componentProps: {
      //     valueFormat: 'YYYY-MM-DD',
      //     disabledDate: (current: Dayjs) => {
      //       return current && current.isAfter(dayjs().startOf('day'), 'day')
      //     }
      //   }
      // },
      {
        field: '[lastChatTimeBegin,lastChatTimeEnd]',
        label: '最近一次咨询时间',
        component: 'RangePicker',
        componentProps: {
          valueFormat: 'YYYY-MM-DD',
          disabledDate: (current: Dayjs) => {
            return current && current.isAfter(dayjs().startOf('day'), 'day')
          }
        }
      },
      {
        field: '[lastVisitTimeBegin,lastVisitTimeEnd]',
        label: '最近一次访问时间',
        component: 'RangePicker',
        componentProps: {
          valueFormat: 'YYYY-MM-DD',
          disabledDate: (current: Dayjs) => {
            return current && current.isAfter(dayjs().startOf('day'), 'day')
          }
        }
      },
      {
        field: 'userMark',
        label: '备注',
        component: 'Input',
        componentProps: {
          maxLength: 200
        }
      }
    ]
  }
}
